package sen.myReport;

import java.util.Enumeration;
import java.util.HashMap;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;

import org.apache.struts.actions.DispatchAction;

public class BasicAction extends DispatchAction{

	/**
	 * 获取表单参数到一个Map里
	 * @param request
	 * @param filters: 要过滤掉的表单名。用中括号括起来，如：[p][test]
	 * @return
	 */
	protected Map<String, String> getParam(HttpServletRequest request, String filters) {
		Map<String, String> param = new HashMap<String, String>();
		
		String[] filterArr = filters.split(",");
		boolean ignorable = false;
		for(Enumeration e  =  request.getParameterNames(); e.hasMoreElements();){
			String key = (String)e.nextElement();
			
			for (int i = 0; i < filterArr.length; i++) {
				if(filterArr[i].equals(key)){
					ignorable = true;
				}
			}
			if(!ignorable) {
				String value = (String)request.getParameter(key);
				param.put(key, value);
			}
			ignorable = false;
		}
		return param;
	}
}